<template>
    <div ref="gameList" class="fullScreen bg-c-wh"> 
        <m-header :msg="data.title"></m-header>
        <div class="scroll-box">
            <div class="flex-box flex-wp">
                <div class="wd-50 tx-c mar-t-5" v-for="(item, i) in data.list" :key="i" @click="getGame(item)"> 
                    <img class="iconSize-9 mar_cp" :src="item.logo"/>
                    <p class="tx-s-14 mar-b">{{ item.title }}</p>
                </div>
            </div>
        </div>
        <no-data v-if="noData"></no-data>
    </div>
</template>
<script type="text/ecmascript-6">
import 'common/css/user.css'
import 'common/css/lottery.css'
import NoData from '../components/noData'
import MHeader from '../components/m-header'
import { isDefine, isEmptyObject } from '../common/js/common'
import { gameOpen } from '../common/js/axiosUtil' 
export default {
    data () {
        return {
            recordList : [], // 中奖纪录列表
            noData : false,
            data : this.$route.query.data
        }
    },
    methods: {
        getGame (data) {
            this.$toast('加载中...', 2000)
            let params = this.$params(1)
            params.append('id', data.id)
            gameOpen(params)
            .then((response)=> {
                this.$toastClose()
                if(response.data.code == 200){
                    // 打开游戏页面
                    this.$router.push({
                        path: '/gameHtml',
                        query: {
                            title: data.title,
                            src: response.data.data.url
                        }
                    })
                }else{
                    this.$logAgain(response.data.msg)
                }
            })
            .catch((error)=> {
                this.$toast('请求服务失败', 2000)
            })
        }
    },
    components: {
        NoData,
        MHeader
    }
}
</script>
<style scoped lang="stylus" rel="stylesheet/stylus">
.scroll-box
    position: fixed
    width: 100%
    top: 2.75rem
    bottom: 0
    overflow: auto
.scroll-box::-webkit-scrollbar
    display: none
.mar_cp
    margin: .5rem auto
</style>

